﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;
using SekretarDataLayer;

namespace Sekretar
{
    public partial class ZaposleniRecView : Common.Forms.RecView
    {
        int id;
        Zaposleni n;
        SekretarDataContext dc = new SekretarDataContext();

        public ZaposleniRecView(int id)
        {
            InitializeComponent();
            this.id = id;
        }

        private void ZaposleniRecView_Load(object sender, EventArgs e)
        {
            if (this.id == 0)
            {
                n = new Zaposleni();
                bsZaposleni.DataSource = n;
            }
            else
            {
                bsZaposleni.DataSource = dc.Zaposlenis.SingleOrDefault(c => c.ZaposleniId == this.id);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.id == 0) dc.Zaposlenis.InsertOnSubmit(n);
            dc.SubmitChanges();
        }
    }
}
